<?php
/**
 * Class ApiController
 */
use wepay\join\demo\common\SignUtil;
use wepay\join\demo\common\DesUtils;
use wepay\join\demo\common\ConfigUtil;
use wepay\join\demo\api\WebAsynNotificationCtrl;
use wepay\join\demo\api\WebBase;
use wepay\join\demo\api\WebSecurity;

class ApiController extends BaseController
{

    /**
     * 构造函数
     *
     * @access   public
     * @return   void
     */
//    public function __construct(){
//        parent::__construct();
////        //投资到期收益入库
//       $Ushouyi=ApiService::instance()->UserAccountshouyi();
////        //体验金到期入库
//       // $Eshouyi=ApiService::instance()->experienceshouyi();
//
//    }

    /**
     * 参数验证
     * @param $obj
     * @param $arr
     * @author lzhp
     * @date 2016-6-25
     * @return bool
     */
    public function  checkProperties($obj, $arr)
    {
        if(empty($arr)) return true;
        $obj    =   (array) $obj;

        foreach($arr as $v){
            if(empty($obj[$v])){
                return false;}
        }
        return true;
    }

    /*_________________________________________规范接口开始_______________________________________________*/




    /**
     * 获取首页数据
     * @author xf
     * @date 2016-06-24
     */
    public function GetIndexData()
    {

        #接收参数
        $page = $this->getParam('page');
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($page)?1:$page;  //页数
        #逻辑处理
        try{
            $Bannedata = ApiService::instance()->BannerShow();
            $IndexData = ApiService::instance()->GetIndexData($paramObj);
            $arr=array(
                'Bannedata' =>$Bannedata ,
                'IndexData' =>$IndexData ,
            );
            return     $this->rest->success($arr, ErrorCodeEnum::STATUS_SUCCESS,"获取首页数据成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 央票通
     * @author xf
     * @date 2016-06-24
     */
    public function GetyptData(){

        #接收参数
        $page = $this->getParam('page');
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($page)?1:$page;  //页数
        #逻辑处理
        try{
            $data = ApiService::instance()->GetyptData($paramObj);
            return     $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取央票通列表数据成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 上市通
     * @author xf
     * @date 2016-06-24
     */
    public function GetsstData(){

        #接收参数
        $page = $this->getParam('page');
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($page)?1:$page;  //页数
        #逻辑处理
        try{
            $data = ApiService::instance()->GetsstData($paramObj);
            return     $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取上市通列表数据成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 央票通详情页
     * @author xf
     * @date 2016-06-27
     */
    public function YptDetailsData(){
        #接收参数
        $project_id     = $this->getParam('project_id');
        $type           = $this->getParam('type');

        #逻辑处理
        try{
            if(empty($project_id )||empty($type)){
                throw new Exception($this->error_msg[ProfessionErrorCodeEnum::STATUS_ERROR_PARAMS_MUST],
                    ProfessionErrorCodeEnum::STATUS_ERROR_PARAMS_MUST);
            }

            $vouchersta    = ApiService::instance()->vouchersta();//现金卷是否过期，修改staue状态
            $data = ApiService::instance()->yptDdetailsData($project_id);
            return     $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取央票通详情数据成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    //现金券
    public function UserAward(){
        $page = $this->getParam('page');
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($page)?1:$page;  //页数

        try{
            //现金劵
            if(empty($paramObj->page)){
                throw new Exception($this->error_msg[ProfessionErrorCodeEnum::STATUS_ERROR_PARAMS_MUST],
                    ProfessionErrorCodeEnum::STATUS_ERROR_PARAMS_MUST);
            }
            $withdraw       = ApiService::instance()->voucher($paramObj);
            $vouchersta     = ApiService::instance()->vouchersta();//现金卷是否过期，修改staue状态
           // return $vouchersta;
            return     $this->rest->success($withdraw, ErrorCodeEnum::STATUS_SUCCESS,"获取现金券成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }


    }

    /**
     * 体验金
     * @author xf
     * @date 2016-06-29
     */
    public  function Experience(){
        try{
            //现金劵
            $experience         = ApiService::instance()->experience();//体验金
            $experiencemoney    = ApiService::instance()->experiencemoney();//计算收益
            $experiencemoney=strval($experiencemoney);
            $arr= array(
                'experience' =>  $experience,
                'expermoney' =>  $experiencemoney,
            );

            return     $this->rest->success($arr, ErrorCodeEnum::STATUS_SUCCESS,"获取体验金成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }


    /**
     * 投资
     * @author xf
     * @date 2016-06-28
     */
    public function ProjectPsay(){
        #接收参数
        $project_id                 = $this->getParam('project_id');
        $type                       = $this->getParam('type');
        $money                      = $this->getParam('money');
        $paramObj                   =new stdClass();
        $paramObj->project_id       =$project_id ;
        $paramObj->type             =$type;
        $paramObj->money            =$money;
        #逻辑处理
        try{

            $vouchersta    = ApiService::instance()->vouchersta();//现金卷是否过期，修改staue状态
            $data = ApiService::instance()->GetdetailsData($paramObj);
            return     $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取预计收益成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 邀请列表
     * @author xf
     * @date 2016-06-29
     */
    public  function UserInvite(){
        $page = $this->getParam('page');
        $paramObj                   =   new stdClass();
        $paramObj->page             =   empty($page)?1:$page;  //页数
        try{
            $reward = ApiService::instance()->Reward($paramObj);//列表
            return     $this->rest->success($reward, ErrorCodeEnum::STATUS_SUCCESS,"获取邀请人列表成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 支付密码提交动作
     *  2016.06.30
     */
    public function AjaxProjectPay()
    {
        if(Request::isMethod('POST')){
            #接收参数
            $paramObj = new stdClass();
            $paramObj->select       =$this->getParam('select');
            $paramObj->pwd          =$this->getParam('pwd');
            $paramObj->moneys       =$this->getParam('money');
            $paramObj->type         =$this->getParam('type');
            $paramObj->project_id   =$this->getParam('project_id');
            try{
                $data = ApiService::instance()->AjaxProjectPay($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "交易成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }


    }


    /**
     * 体验标支付动作
     */
    public  function  ProjectDeEexperience(){
        //post提交
        if(Request::isMethod('POST')){
            $paramObj = new stdClass();
            $paramObj->experience   =$this->getParam('experience');
            #逻辑处理
            try{
                $data = ApiService::instance()->AjaxSubmitExperient($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "支付成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }
    }


    /**
     * 京东支付
     * @author xf
     * @data 2016-7-1
     */
    public function JdPay()
    {
        $config = Config::get("jd_pay");
        $successCallbackUrl = $config["successCallbackUrl"];
        $failCallbackUrl = $config["failCallbackUrl"];
        $merchantNum = $config["merchantNum"];
        $notifyUrl = "http://api.yangpiaotong.com/Api/check_Sign";
        $serverPayUrl = $config["serverPayUrl"];
        $param                          =       [];
        $param['currency']              =      "CNY";//货币类型
        $param['merchantNum']           =       $merchantNum;//商户号
        $param['merchantRemark']        =       "央票通 —— 账户余额充值";//商户备注信息
        $param['failCallbackUrl']       =      $failCallbackUrl;//失败跳转地址
        $param['notifyUrl']             =      $notifyUrl;
        $param['successCallbackUrl']    =      $successCallbackUrl;
        $param['tradeAmount']           =       $this->getParam('amount')*100;//$_SESSION['array']['amount']*100;//订单金额
        //$param['tradeAmount']           =   1;//订单金额
        $param['tradeDescription']      =       "央票通 —— 账户余额充值";//订单描述
        $param['tradeName']             =       "央票通 —— 账户余额充值";//订单标题
        // $param['tradeNum']              =       $_SESSION['array']['trade_num'];//交易流水号
        // $param['tradeTime']             =       date('Y-m-d H:i:s',$_SESSION['array']['order_time']); //订单时间
        $param['tradeNum']              =      ConfigUtil::get_trade_num().$this->getParam('uid');
        $param['tradeTime']             =       date('Y-m-d H:i:s', time());
        $param['version']               =       "3.0";
        $param['token']                 =       "";
        $specialJson = array();
        $specialJson["specBankCardNo"]        =$this->getParam('specBankCardNo');//$_GET['specBankCardNo']; //银行卡
        $param["specifyInfoJson"]       = json_encode($specialJson);
        // return  $param['tradeNum'];
        $sign = SignUtil::sign($param);
        $param["merchantSign"] = $sign;
        //敏感信息加密
        $_SESSION['tradeAmount'] = $param["tradeAmount"];
        $_SESSION['tradeName'] = $param["tradeName"];
        //获取商户 DESkey
        //对敏感信息进行 DES加密
        $desUtils  = new DesUtils();
        $key = $config["desKey"];
        $param["merchantRemark"]    =   $desUtils->encrypt($param["merchantRemark"],$key);
        $param["tradeNum"]          =   $desUtils->encrypt($param["tradeNum"],$key);
        $param["tradeName"]         =   $desUtils->encrypt($param["tradeName"],$key);
        $param["tradeDescription"]  =   $desUtils->encrypt($param["tradeDescription"],$key);
        $param["tradeTime"]         =   $desUtils->encrypt($param["tradeTime"],$key);
        $param["tradeAmount"]       =   $desUtils->encrypt($param["tradeAmount"],$key);
        $param["currency"]          =   $desUtils->encrypt($param["currency"],$key);
        $param["notifyUrl"]         =   $desUtils->encrypt($param["notifyUrl"],$key);
        $param["successCallbackUrl"] =  $desUtils->encrypt($param["successCallbackUrl"],$key);
        $param["failCallbackUrl"]    =  $desUtils->encrypt($param["failCallbackUrl"],$key);
        $param["specifyInfoJson"]    =  $desUtils->encrypt($param["specifyInfoJson"],$key);
        $_SESSION['tradeInfo'] = $param;
        //return $param;
        // return Redirect::to('/Api/pay_submit_test');
        $paramObj                          =          new stdClass();
        $paramObj->specBankCardNo          =          $this->getParam('specBankCardNo');
        $paramObj->uid                     =          $this->getParam('uid');
        $info = ApiService::instance()->UserMoneyajax($paramObj);

        return $this->view('index.pay_submit');
    }
    /**
     * 异步通知
     */
    public function CheckSign() {
        $MD5_KEY="zQmMsDHKkJnbfpwaoyjqmdqrsbOrMloB";
        $DES_KEY="nZFFhbWP8ftPhrUNlyAT0MLsW9/0iR/j";
        $webAsy = new WebAsynNotificationCtrl();
        $data =$webAsy->execute($MD5_KEY,$DES_KEY,$this->getParam('resp'));
        $xml = simplexml_load_string($data); //创建 SimpleXML对象
        $data = json_decode(json_encode($xml),TRUE);
        // #收集信息
        // return $data;
        $paramObj = new stdClass();
        $paramObj->id                   =$data['TRADE']['ID'];
        $paramObj->amount               =$data['TRADE']['AMOUNT']/100;
        $paramObj->time                 =time();
        $paramObj->success              =$data['RETURN']['DESC'];
        $paramObj->uid                  =substr($data['TRADE']['ID'],13,8);
        if($data['RETURN']['CODE']==0000){
            $asd= ApiService::instance()->Rechargeinsert($paramObj);
            $ass= ApiService::instance()->Checkinsert($paramObj);
            $extend = ApiService::instance()->Extendmoney($paramObj);

        }
        return 'success';

    }
    /**
     * 提现动作
     * @return mixed
     */
    public function AjaxUserMone(){
        if(Request::isMethod('POST')){
            // if(!get_magic_quotes_gpc()){//防sql
            //     $paramObj = new stdClass();
            //     $paramObj->moneysum         =addslashes($this->getParam('moneysum'));
            //     $paramObj->pay_pwd          =addslashes($this->getParam('pay_pwd'));
            // }else{
            $paramObj = new stdClass();
            $paramObj->moneysum         =$this->getParam('moneysum');
            $paramObj->pay_pwd          =$this->getParam('pay_pwd');
            // }
            try{
                $data = ApiService::instance()->AjaxWithdraw($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "提现成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
            //print_r($info);
        }

    }


    /**
     * 个人中心金额
     * @param $paramObj
     * @return int
     */
    public function UserAccount()
    {
        #逻辑处理
        try{
            $experience   =ApiService::instance()->experience();//体验金
           $voustatue    =ApiService::instance()->UserAccountstatue();//投资记录时间修改
            $datpende     =ApiService::instance()->UserAccountpende();//账户信息收益正在进行
            $dasusful     =ApiService::instance()->UserAccountsussful();//账户信息收益完成的
            $daExtend     =ApiService::instance()->UserExtendone();//可用余额

            //投资到期收益入库
                   $Ushouyi=ApiService::instance()->UserAccountshouyi();

            //体验金到期入库
            $Eshouyi=ApiService::instance()->experienceshouyi();

            $datpende=strval($datpende);
            //print_r($daExtend);
            $dasusful=strval($dasusful);
            $UserInfone     =ApiService::instance()->UserInfone();//个人信息
            $UseBankManager     =ApiService::instance()->UseBankManager();//个人信息

            $arr =array();
            if($UseBankManager){
                foreach($UseBankManager as $k=>$v){
                    if($v==''){
                        $arr[$k] = '';
                    }else{
                        $arr[$k] = $v;
                    }
                }
            }else{
                $arr = null;
            }
            $arr2 = array();
            if($UserInfone){
                foreach($UserInfone as $k=>$v){
                    if($v==''){
                        $arr2[$k] = '';
                    }else{
                        $arr2[$k] = $v;
                    }
                }
            }else{
                $arr2 = null;
            }


            $data= array(
                'datpende'      =>$datpende,
                'dasusful'      =>$dasusful,
                'daExtend'      =>strval($daExtend->user_balance),
                'user_info'     =>$arr2,
                'bank_info'     =>$arr,
            );


            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "收益接受成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }



    /**
     * APP初始化
     * @author lzhp
     * @date 2016-07-08
     */
    public function IndexApp(){
        try{
            $data = ApiService::instance()->GetIndexApp();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS,"获取APP信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 用户注册
     * @author lzhp
     * @data 2016-6-25
     */
    public function DeposeRegister()
    {
        #接收参数
        $paramObj                       =          new stdClass();
        $paramObj->mobile               =          $this->getParam('mobile');               //手机号
        $paramObj->password             =          $this->getParam('password');             //密码
        $paramObj->invite_mobile        =          $this->getParam('invite_mobile');        //邀请人手机号


        #逻辑处理
        try{
            $data = ApiService::instance()->DeposeRegister($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "注册成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 注册手机验证
     * @author lzhp
     * @data 2016-6-27
     */
    public function RegisterMobile()
    {
        #接收参数
        $paramObj                       =          new stdClass();
        $paramObj->mobile               =          $this->getParam('mobile');               //手机号

        #逻辑处理
        try{
            $data = ApiService::instance()->RegisterMobile($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "手机号可用!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 用户登录
     * @author lzhp
     * @data 2016-6-25
     */
    public function DeposeLogin()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');
        $paramObj->password         =          $this->getParam('password');


        #逻辑处理
        try{
            $data = ApiService::instance()->DeposeLogin($paramObj);
            return Response::json([
                'code' => ErrorCodeEnum::STATUS_SUCCESS,
                'msg'  => '登录成功!',
                'data' => $data
            ]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 自动登录
     */
    public function AutoLogin()
    {
        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->user_id           =          $this->getParam('user_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->AutoLogin($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "自动登录!");

        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }
    /**
     * 注销用户
     * @author  lzhp
     * @date 2016-6-25
     */
    public function LoginOut()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->LoginOut();
            return Response::json([
                'code' => ErrorCodeEnum::STATUS_SUCCESS,
                'msg'  => '注销成功!',
                'data' => $data
            ]);
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }



    /**
     * 忘记密码手机验证
     * @author lzhp
     * @data 2016-6-27
     */
    public function ForgetPasswordMobile()
    {

        #收集信息
        $paramObj                   =          new stdClass();
        $paramObj->mobile           =          $this->getParam('mobile');

        #逻辑处理
        try{
            $data = ApiService::instance()->ForgetPasswordMobile($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "手机号可用!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 忘记密码
     * @author lzhp
     * @data 2016-6-27
     */
    public function ForgetPassword()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->mobile                  =          $this->getParam('mobile');
        $paramObj->password                =          $this->getParam('password');

        #逻辑处理
        try{
            $data = ApiService::instance()->ForgetPassword($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "密码修改成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 实名认证
     * @author lzhp
     * @data 2016-6-28
     */
    public function AuthName()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->real_name               =          $this->getParam('real_name');
        $paramObj->id_card                 =          $this->getParam('id_card');

        #逻辑处理
        try{
            $data = ApiService::instance()->AuthName($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "认证信息可用!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 支付密码
     * @author lzhp
     * @data 2016-6-28
     */
    public function PayPassword(){

        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->real_name               =          $this->getParam('real_name');
        $paramObj->id_card                 =          $this->getParam('id_card');
        $paramObj->pay_pwd                 =          $this->getParam('pay_pwd');

        #逻辑处理
        try{
            $data = ApiService::instance()->PayPassword($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "实名认证成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 修改支付密码
     * @author lzhp
     * @data 2016-6-29
     */
    public function UpPayPassword()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->mobile                  =          $this->getParam('mobile');
        $paramObj->pay_pwd                 =          $this->getParam('pay_pwd');

        #逻辑处理
        if($paramObj->mobile&&$paramObj->pay_pwd){
            try{
                $data = ApiService::instance()->UpPayPassword($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "修改支付密码成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }else{
            try{
                $data = ApiService::instance()->UpPayPasswordMobile($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "手机号正确!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }

    }
    /**
     * 修改登录密码
     * @author lzhp
     * @data 2016-6-29
     */

    public function UpLoginPassword()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->old_pwd                 =          $this->getParam('old_pwd');
        $paramObj->new_pwd                 =          $this->getParam('new_pwd');

        #逻辑处理
        try{
            $data = ApiService::instance()->UpLoginPassword($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "修改登录密码成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 投资记录
     * @author lzhp
     * @data 2016-6-29
     */
    public function InvestRecord()
    {
        $page = $this->getParam('page');
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->page                    =          empty($page)?1:$page;
        $paramObj->year                    =          $this->getParam('year');
        $paramObj->month                   =          $this->getParam('month');

        #逻辑处理
        try{
            $data = ApiService::instance()->InvestRecord($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "投资记录查询成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 消息中心
     * @author lzhp
     * @data 2016-6-30
     */
    public function MessageCenter()
    {
        $page = $this->getParam('page');
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->page                    =          empty($page)?1:$page;
       // $paramObj->user_id                 =          $this->getParam('user_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->MessageCenter($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "消息列表成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 银行卡绑定
     * @author lzhp
     * @data 2016-6-30
     */
    public function BankBound()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->province                =          $this->getParam('province');              //省会
        $paramObj->city                    =          $this->getParam('city');                  //城市
        $paramObj->area                    =          $this->getParam('area');                  //地区
        $paramObj->real_name               =          $this->getParam('real_name');             //真实姓名
        $paramObj->id_card                 =          $this->getParam('id_card');               //身份证
        $paramObj->kaihuhang               =          $this->getParam('kaihuhang');             //开户行
        $paramObj->bank_name               =          $this->getParam('bank_name');             //银行名称
        $paramObj->bank_num                =          $this->getParam('bank_num');              //银行卡号
        $paramObj->bank_code               =          $this->getParam('bank_code');             //银行编码
        $paramObj->bank_token              =          $this->getParam('bank_token');            //token


        #逻辑处理
        try{
            $data = ApiService::instance()->BankBound($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "验证码发送成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 银行卡修改
     * @author lzhp
     * @data 2016-6-30
     */
    public function BankUp()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->user_id                 =          $this->getParam('user_id');               //用户id
        $paramObj->province                =          $this->getParam('province');              //省会
        $paramObj->city                    =          $this->getParam('city');                  //城市
        $paramObj->area                    =          $this->getParam('area');                  //地区
        $paramObj->real_name               =          $this->getParam('real_name');             //真实姓名
        $paramObj->id_card                 =          $this->getParam('id_card');               //身份证
        $paramObj->kaihuhang               =          $this->getParam('kaihuhang');             //开户行
        $paramObj->bank_name               =          $this->getParam('bank_name');             //银行名称
        $paramObj->bank_num                =          $this->getParam('bank_num');              //银行卡号
        $paramObj->bank_token              =          $this->getParam('bank_token');            //token
        $paramObj->bank_code               =          $this->getParam('bank_code');             //银行编码


        #逻辑处理
        try{
            $data = ApiService::instance()->BankUp($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取token成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }


    public function BankConfirm()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->user_id                 =          $this->getParam('user_id');               //用户id
        $paramObj->province                =          $this->getParam('province');              //省会
        $paramObj->city                    =          $this->getParam('city');                  //城市
        $paramObj->area                    =          $this->getParam('area');                  //地区
        $paramObj->real_name               =          $this->getParam('real_name');             //真实姓名
        $paramObj->id_card                 =          $this->getParam('id_card');               //身份证
        $paramObj->kaihuhang               =          $this->getParam('kaihuhang');             //开户行
        $paramObj->bank_name               =          $this->getParam('bank_name');             //银行名称
        $paramObj->bank_num                =          $this->getParam('bank_num');              //银行卡号
        $paramObj->bank_code               =          $this->getParam('bank_code');             //银行编码
        $paramObj->bank_token              =          $this->getParam('bank_token');            //token
        $paramObj->verify                  =          $this->getParam('verify');                //短信验证码

        #逻辑处理
        if(empty($paramObj->user_id)){
            try{
                $data = ApiService::instance()->BankRealBound($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "银行卡绑定成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }else{
            try{
                $data = ApiService::instance()->BankRealUp($paramObj);
                $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "银行卡信息修改成功!");
            }catch(Exception $e){
                $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
            }
        }

    }

    /**
     * 银行卡删除
     * @author lzhp
     * @data 2016-6-30
     */
    public function BankDel()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->user_id                 =          $this->getParam('user_id');               //用户id
        $paramObj->pay_pwd                 =          $this->getParam('pay_pwd');               //支付密码


        #逻辑处理
        try{
            $data = ApiService::instance()->BankDel($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "银行卡删除成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }

    }

    /**
     * 投标记录查询
     * @author lzhp
     * @date 2016-06-30
     */
    public function BidRecord()
    {
        $page = $this->getParam('page');
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->page                    =          empty($page)?1:$page;
        $paramObj->project_id              =          $this->getParam('project_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->BidRecord($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "投标记录查询成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }
    /**
     * 体验标投标记录查询
     * @author lzhp
     * @date 2016-06-30
     */
    public function ExperBidRecord()
    {
        $page = $this->getParam('page');
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->page                    =          empty($page)?1:$page;

        #逻辑处理
        try{
            $data = ApiService::instance()->ExperBidRecord($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "体验标投标记录查询成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 银行卡表
     * @author lzhp
     * @date 2016-07-01
     */
    public function BankCard()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->BankCard();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "银行卡列表!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 获取银行卡信息
     * @author lzhp
     * @date 2016-07-05
     */
    public function BankInfo()
    {

        #逻辑处理
        try{
            $data = ApiService::instance()->BankInfo();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取银行卡信息成功!");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }


    /**
     * 资产日历
     * @author lzhp
     * @date 2016-07-07
     */
    public function Calendar()
    {
        #收集信息
        $paramObj                          =          new stdClass();
        $paramObj->year                    =          $this->getParam('year');
        $paramObj->month                   =          $this->getParam('month');
        $paramObj->day                     =          $this->getParam('day');
        $paramObj->user_id                 =          $this->getParam('user_id');

        #逻辑处理
        try{
            $data = ApiService::instance()->Calendar($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取资产日历信息成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 获取个人信息
     * @author lzhp
     * @date 2016-07-14
     */
    public function GetUserInfo()
    {
        #逻辑处理
        try{
            $data = ApiService::instance()->GetUserInfo();
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "获取个人信息成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }

    /**
     * 消息状态修改
     * @author lzhp
     * @date 2016-07-15
     */
    public function MessageStatus()
    {
        #收集信息
        $paramObj                             =          new stdClass();
        $paramObj->user_id                    =          $this->getParam('user_id');
        $paramObj->message_id                 =          $this->getParam('message_id');


        #逻辑处理
        try{
            $data = ApiService::instance()->MessageStatus($paramObj);
            $this->rest->success($data, ErrorCodeEnum::STATUS_SUCCESS, "消息状态修改成功");
        }catch(Exception $e){
            $this->rest->error($e->getMessage(), $e->getCode(),new stdClass());
        }
    }



    /**
     * 保理服务合同展示
     * @return mixed
     * @author lzhp
     * @date 2016-07-04
     */
    public function ReadWord()
    {
        return $this->view('index.read_word');

    }

    public function RegisterProtocol()
    {
        return $this->view('index.register_protocol');
    }

    /**
     * 邀请好友
     * @return mixed
     * @author lzhp
     * @date 2016-07-14
     */
    public function YptAppInvite()
    {
        return $this->view('index.ypt_app_invite');
    }

    /**
     * 关于我们
     * @author lzhp
     * @date 2016-07-14
     */
    public function AboutUs()
    {
        return $this->view('index.about_us');
    }


    /**
     * 信鸽
     */
    public function XG()
    {

//        $user_id               =          $this->getParam('user_id');
//        $title                 =          $this->getParam('title');
//        $content               =          $this->getParam('content');
//
      return ApiService::instance()->XG(118,'11','22');
    }

    /*____________________________________________规范接口结束______________________________________________________*/

}
